/*
 * @Description:
 * @Date: 2023-11-01 20:45:16
 * @LastEditTime: 2023-12-20 21:41:18
 */
import { createVNode, render } from 'vue';
import Dialog from './index.vue';
const divDom = document.createElement('div');
divDom.setAttribute('class', 'u-dialog-modal-container');
document.body.appendChild(divDom);

const dialogPlguin = option => {
	return new Promise((resolve, reject) => {
		const okButton = () => {
			//确认
			render(null, divDom);
			resolve(vNode);
		};
		const cancelButton = () => {
			//  取消
			render(null, divDom);
			reject(new Error('取消'));
		};

		const vNode = createVNode(Dialog, { ...option, okButton, cancelButton });
		render(vNode, divDom);
	});
};
export default dialogPlguin;

//第二种方式
// export default {
// install(app) {
//     app.config.globalProperties.$dialog = dialogPlguin
// }
//main.js中引入
//import dialog from './utils/dialog'
//app.use(dialog).mount('#app')
// }
